#ifndef _DRV_SPI_H
#define _DRV_SPI_H

#include "stm32f10x.h"

#define PORT_SPI_CS               GPIOA
#define PORT_SPI_SCK              GPIOC
#define PORT_SPI_MISO             GPIOC
#define PORT_SPI_MOSI             GPIOC
#define PIN_SPI_CS                GPIO_Pin_15
#define PIN_SPI_SCK               GPIO_Pin_0
#define PIN_SPI_MISO              GPIO_Pin_2
#define PIN_SPI_MOSI              GPIO_Pin_3
#define SPI_CS_ENABLE             (PORT_SPI_CS->BRR  = PIN_SPI_CS)
#define SPI_CS_DISABLE            (PORT_SPI_CS->BSRR = PIN_SPI_CS)
#define SPI_SCK_LOW               (PORT_SPI_SCK->BRR  = PIN_SPI_SCK)
#define SPI_SCK_HIGH              (PORT_SPI_SCK->BSRR = PIN_SPI_SCK)
#define SPI_MISO_READ             (PORT_SPI_MISO->IDR & PIN_SPI_MISO)
#define SPI_MOSI_LOW              (PORT_SPI_MOSI->BRR  = PIN_SPI_MOSI)
#define SPI_MOSI_HIGH             (PORT_SPI_MOSI->BSRR = PIN_SPI_MOSI)

void spi_initial(void);
void spi_write_byte(uint8_t TxData);
uint8_t spi_read_byte(void);

#endif /* _SPI_H */

